package gui;

import java.awt.FlowLayout;

import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.JTextField;

public class NumberInput extends JComponent {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private JTextField first;
	private JTextField second;
	public NumberInput(String name,double num) {
		
		double exp = num == 0 ? 0 : Math.log10(Math.abs(num));
		exp = Math.floor(exp);
		double start = num == 0 ? 0 : num / Math.pow(10, exp);
		System.out.println("setup : exp = "+exp+", start = "+start);
		first = new JTextField(Double.toString(start),11);
		second = new JTextField(Double.toString(exp),4);
		setLayout(new FlowLayout());
		add(new JLabel(name));
		add(first);
		add(new JLabel("*10^"));
		add(second);
	}
	public double getNum() {
		double one = Double.parseDouble(first.getText());
		double two = Double.parseDouble(second.getText());
		System.out.println("done : 1 = "+one+", 2 = "+two);
		return one*Math.pow(10,two);
	}
}
